/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 *
 */
package com.google.code.bigyang.buffer;

import java.io.InputStream;
import java.io.OutputStream;
import com.google.code.bigyang.util.Dumpable;

public interface Buffer extends Dumpable {

	public enum Order {
		BIG_ENDIAN,
		LITTLE_ENDIAN,
	}
	
	public Buffer clear();
	
	public boolean hasRemaining();
	
	public int limit();
	
	public int position();
	
	public int capacity();
	
	public Buffer order(Order order);
	
	public Order getOrder();
	
	
	// --------------------
	public Buffer wrap(byte[] buf);
	
	public Buffer wrap(byte[] buf,int offset,int len);
	
	public Buffer compact();
	
	
	public boolean hasArray();
	
	public byte[] array();
	
	public Buffer free();
	
	public boolean isReadOnly();
	
	public boolean isAutoExpand();
	
	public Buffer setAutoExpand(boolean autoExpand);
	
	public Buffer expand(int size);
	
//	public Buffer expand(int position,int size);
	
	
	public boolean isAutoShrink();
	
	public Buffer setAutoShrink(boolean autoShrink);
	
	public Buffer shrink();
	
	public Buffer mark();
	
	public Buffer reset();	
	
	public InputStream asInputStream();
	
	public OutputStream asOutputStream();
	
	
	//=========================
	public Buffer putByte(byte b);
	
	public Buffer putByte(int index,byte b);
	
	public Buffer putBytes(byte[] buf);
	
	public Buffer putBytes(byte[] buf,int offset,int len);
	
	public byte getByte();
	
	public byte getByte(int index);
	
	public Buffer getBytes(byte[] buf);
	
	public Buffer getBytes(byte[] buf,int offset,int len);
	
	
	public Buffer putShort(short s);
	
	public Buffer putShort(int index,short s);
	
	public short getShort();
	
	public short getShort(int index);
	
	
	public Buffer putInt(int i);
	
	public Buffer putInt(int index,int i);
	
	public int getInt();
	
	public int getInt(int index);
	
	
	public Buffer putLong(long v);
	
	public Buffer putLong(int index,long v);
	
	public long getLong();
	
	public long getLong(int index);
	
	
	public Buffer putFloat(float f);
	
	public Buffer putFloat(int index,float f);
	
	public float getFloat();
	
	public float geteFloat(int index);
	
	/**
	 * 
	 * @param d
	 * @return
	 */
	public Buffer putDouble(double d);
	
	public Buffer putDouble(int index,double d);
	
	public double getDouble();
	
	public double getDouble(int index);
	
	public int remaining();
	
	
}
